package com.zoffy.oj_backend.model.vo;

import cn.hutool.json.JSONUtil;
import com.zoffy.oj_backend.judge.codesandbox.model.JudgeInfo;
import com.zoffy.oj_backend.model.entity.QuestionSubmit;
import lombok.Data;
import org.springframework.beans.BeanUtils;

@Data
public class QuestionSubmitTinyVo {
    /**
     * id
     */
    private Long id;

    /**
     * 编程语言
     */
    private String lang;


    /**
     * 判题信息
     */
    private JudgeInfo judgeInfo;

    /**
     * 判题状态(0-待判，1-判题中，2-成功，3-失败)
     */
    private Integer state;

    /**
     * 题目id
     */
    private Long questionId;

    /**
     * 用户id
     */
    private Long userId;
    public static QuestionSubmitTinyVo obj2Vo(QuestionSubmit questionSubmit){


        QuestionSubmitTinyVo questionSubmitTinyVo = new QuestionSubmitTinyVo();
        questionSubmitTinyVo.setId(questionSubmit.getId());
        questionSubmitTinyVo.setLang(questionSubmit.getLang());
        questionSubmitTinyVo.setState(questionSubmit.getState());
        questionSubmitTinyVo.setQuestionId(questionSubmit.getQuestionId());
        questionSubmitTinyVo.setUserId(questionSubmit.getUserId());

        questionSubmitTinyVo.setJudgeInfo(JSONUtil.toBean(questionSubmit.getJudgeInfo(), JudgeInfo.class));
        return questionSubmitTinyVo;

    }
}
